<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "user_auth_group".
 *
 * @property int $id
 * @property string $name 名称
 * @property string $rules 权限规则ID
 * @property int $status 状态
 *
 * @property UserAuthGroupAccess[] $userAuthGroupAccesses
 * @property UserAuthRule[] $userAuthRules
 */
class UserAuthGroup extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_auth_group';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['rules'], 'string'],
            [['status'], 'integer'],
            [['name'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '名称',
            'rules' => '权限规则ID',
            'status' => '状态',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserAuthGroupAccesses()
    {
        return $this->hasMany(UserAuthGroupAccess::className(), ['user_auth_group_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserAuthRules()
    {
        return $this->hasMany(UserAuthRule::className(), ['pid' => 'id']);
    }
}
